package hiho.week._68;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		String[] map = new String[n];
		for (int i = 0; i < n; i++)
			map[i] = in.next();

		String[] mark = new String[3];
		for (int i = 0; i < 3; i++)
			mark[i] = in.next();

		String[] location = new String[4];
		// up
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < 3; i++)
			sb.append(mark[i]);
		location[0] = sb.toString();
		// down
		sb = new StringBuilder();
		for (int i = 2; i >= 0; i--)
			for (int j = 2; j >= 0; j--)
				sb.append(mark[i].charAt(j));
		location[1] = sb.toString();
		// left
		sb = new StringBuilder();
		for (int j = 0; j < 3; j++)
			for (int i = 2; i >= 0; i--)
				sb.append(mark[i].charAt(j));
		location[2] = sb.toString();
		// right
		sb = new StringBuilder();
		for (int j = 2; j >= 0; j--)
			for (int i = 0; i < 3; i++)
				sb.append(mark[i].charAt(j));
		location[3] = sb.toString();
		
		for (int i = 0; i <= n - 3; i++)
			for (int j = 0; j <= m - 3; j++) {
				sb = new StringBuilder();
				for (int p = 0; p < 3; p++)
					sb.append(map[i + p].substring(j, j + 3));
				String position = sb.toString();
				boolean right = false;
				for (int p = 0; p < 4; p++)
					if (position.equals(location[p])) {
						right = true;
						break;
					}
				if (right)
					System.out.println((i + 2) + " " + (j + 2));
			}
	}

}
